import {
	setToken,
	getsToken,
	romoveToke
} from '@/utils/token.js'
import api from '../../api/index.js'
export default {
	state: {
		UserINfo: {},
		token: "",
		isLogin: false,
	},
	mutations: {
		GETTOKEN(state, value) {
			state.token = value
			setToken(value)
		},
		GETUSERINFO(state, value) {
			state.UserINfo = value
			state.isLogin = true
		},
		LOGOUT(state, value){
			romoveToke()
			state.UserINfo={}
			state.isLogin=false
			state.token=""
		}
	},
	actions: {
		async getUserInfo({
			commit
		}) {
			let res = await api.user.getUserInfo()
			if (res.code == 200) {
				commit("GETUSERINFO", res.data)
			}
		}
	}
}
